import React from 'react';
import axios from 'axios';
import { withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
//@withRouter

class AuthRoute extends React.Component {
    componentDidMount() {
        const publicList = ['/login', '/register'];
        const pathname = this.props.location.pathname;
        //console.log(this.props.location);
        console.log(pathname);
        if (publicList.indexOf(pathname) > -1) {
            return null;
        }else{
            this.props.dispatch({type:'user/getInfo'});
        }
        //获取用户信息
        // axios.get('http://127.0.0.1:3005/info').
        //     then(res => {
        //         if (res.status == 200) {
        //             if (res.data.code == 0) {
        //                 // 有登录信息de
        //                 //this.props.loadData(res.data.data);
        //                 console.log('123');
        //             }
        //             else {
        //                 this.props.history.push('/login');
        //             }
        //         }
        //     });
    }
    render() {
        return null;
    }
}
const mapStateProps = (state)=>{
    return{

    }
}
export default withRouter(connect(mapStateProps)(AuthRoute));